<?php
$courtTypeList = Blyn::app()->getActiveApp()->getCourtTypeList();
$city = Blyn::app()->getCurrentUser()->getAttribute('myCity_app' . Blyn::app()->getActiveApp()->getId())->getValue();
$regionList = Blyn::app()->getActiveApp()->getRegionList($city);
$app = Blyn::app()->getActiveApp();
$i = 0;
foreach ($courtTypeList as $type => $name) {
    $courtTitle = '<legend><h4>' . $name . '</h4></legend>';
    ?>    
    <?php
    $i = 0;
    foreach ($regionList as $regionName => $regionValue) {

        $findText = 'region=' . $regionName . ' courtType=' . $type;
//                        var_dump($findText);
        $count = $app->findCountByFindText($findText, array('itemMatch' => '='));

        if (is_numeric($count) && $count > 0) {
            if ($i == 0)
                echo $courtTitle;
            ?>
            <div><strong><?php echo $regionValue; ?>---还有：</strong>
                <?php
                echo $control->getAjaxLink(array('name' => $count . '个场地', 'id' => 'showBookingList'), array(
                    'findText' => $findText,
                    'findContext' => serialize(array('findType' => 'fast', 'itemMatch' => '=')),
                ));
                //Blyn::app()->getUIManager()->getCurrentScreen()->addContextVariable('bookableListFindContext', $findContext);
                ?>
                可以预定</div>
            <?php
        }
        $i++;
    }
}


/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

